package meijuli.com.join51.business.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.bumptech.glide.Glide;
import meijuli.com.join51.business.R;

/**
 * 图片详情展示页面
 *
 * @author wenqin 2017-05-10 15:18
 */

public class ImageActivity extends BaseActivity {
    private static final String KEY_IMAGE = "image";
    ImageView mImage;
    LinearLayout mImageLayout;

    public static void start(Activity activity, String url) {
        Intent intent = new Intent(activity, ImageActivity.class);
        intent.putExtra(KEY_IMAGE, url);
        activity.startActivity(intent);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_image);
        mImage = findViewById(R.id.image);
        mImageLayout = findViewById(R.id.image_layout);
        String url = getIntent().getStringExtra(KEY_IMAGE);
        Glide.with(this)
                .load(url)
                .error(R.mipmap.icon_header)
                .crossFade()
                .into(mImage);
        mImageLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}
